package com.springjooq.sdun.config.web;

import org.apache.shiro.web.filter.AccessControlFilter;
import org.apache.shiro.web.util.WebUtils;
import org.springframework.util.StringUtils;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

/**
 * @Description
 * @auther Szper
 * @create 2019-08-26 15:16
 */
public class MyTokenFilter extends AccessControlFilter {

    @Override
    protected boolean isAccessAllowed(ServletRequest servletRequest, ServletResponse servletResponse, Object o) throws Exception {
        String permission = WebUtils.getPathWithinApplication(WebUtils.toHttp(servletRequest)).substring(0);
        if(StringUtils.isEmpty(permission))
            return true;
        return false;
    }

    @Override
    protected boolean onAccessDenied(ServletRequest servletRequest, ServletResponse servletResponse) throws Exception {
        return false;
    }
}
